package com.juc.callable.callable2;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class Run {
    /**
     * submit 传入Callable接口则可以有返回值
     * 如果传入Runnable则无返回值，打印结果为null
     * 方法get()有阻塞的特性 而isDone()没有阻塞特性
     * @param args
     * @throws InterruptedException
     * @throws ExecutionException
     */
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		Runnable runnable = new Runnable() {
			
			@Override
			public void run() {
				System.out.println("打印的信息");
			}
		};
		ExecutorService executorService = Executors.newCachedThreadPool();
		Future future = executorService.submit(runnable);
		System.out.println(future.get() + "   " + future.isDone());
	}
}
